package testing;

import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;
import java.sql.SQLException;

import se.kth.id2212.bankjdbc.*;

import common.ItemImpl;

import client.Trader;
import client.TraderImpl;

import server.Marketplace;
import server.MarketplaceImpl;

public class MarketplaceTest {

	/**
	 * @param args
	 * @throws NotBoundException 
	 * @throws MalformedURLException 
	 * @throws RemoteException 
	 * @throws SQLException 
	 * @throws ClassNotFoundException 
	 */
	public static void main(String[] args) throws RemoteException, MalformedURLException, NotBoundException, SQLException, ClassNotFoundException {
		MarketplaceImpl mp = new MarketplaceImpl();
		TraderImpl asd = new TraderImpl("kii", "123", mp);
		mp.registerTrader(asd);
		System.out.println("Current balance " + mp.getAccountBalance("kim"));
		//Item i = new Item("ki","camera",2000);
		//mp.sellItem(i);
		mp.watchForItem("camera", 3000, "kii");
		
		mp.watchForItem("tv", 4000, "kii");
		
		try {
			Thread.sleep(10000);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		System.out.println("Adding watched item");
		
		//mp.sellItem(new Item("kim", "tv", 4000));
		
		mp.logout("kii");
		
		mp.login("kii", "123");

	}

}
